<template>
  <HomePannel :title="'人气推荐'" :subTitle="'人气爆款 不容错过'">
      <div ref="box" style="position: relative;height: 406px;">
      <Transition name="fade">
          <ul v-if="list.length" ref="pannel"  class="goods-list">
          <li v-for="item in list" :key="item.id">
              <router-link :to="`/product/${item.id}`">
              <img  v-lazy="item.picture" :alt="item.alt">
              <p class="name">{{item.title}}</p>
            <p class="desc">{{item.alt}}</p>
              </router-link>
          </li>
      </ul>
      <HomeSkeleton v-else />
      </Transition>
      </div>
  </HomePannel>
</template>

<script>
import { findHot } from '@/api/home'
import { ref } from 'vue'
import HomePannel from './home-pannel.vue'
import HomeSkeleton from './home-skeleton.vue'
import { useLayzyData } from '@/hooks'
export default {
  components: {
    HomePannel,
    HomeSkeleton
  },
  setup () {
    // const list = ref([])
    // findHot().then(data => {
    //   list.value = data.result
    // })
    const box = ref(null)
    // findNew().then(data => {
    //   list.value = data.result
    // })

    const list = useLayzyData(box, findHot)
    // debugger
    return { list, box }
  }
}
</script>

<style scoped lang="less">
.home-panel {
  background:#fff
}
.goods-list {
  display: flex;
  justify-content: space-between;
  height: 406px;
  li {
    width: 306px;
    height: 406px;
    .hoverShadow();
    img {
      width: 306px;
      height: 306px;
    }
    p {
      font-size: 22px;
      padding: 12px 30px 0 30px;
      text-align: center;
    }
    .price {
      color: @priceColor;
    }
     .desc {
      color: #999;
      font-size: 18px;
    }
  }
}
</style>
